from django.urls import path
from rest_framework.routers import DefaultRouter
from posts import views

router = DefaultRouter()

router.register('posts', views.PostViewSet)
router.register('comments', views.CommentViewSet)

urlpatterns = [
    # 帖子相关API
    path('posts/', views.PostViewSet.as_view({'get': 'list'}), name='post_list'),
    
    # 点赞相关API
    path('<int:post_id>/like/', views.PostLikeAPIView.as_view(), name='post_like'),
    
    # 收藏相关API
    path('<int:post_id>/star/', views.PostStarAPIView.as_view(), name='post_star'),
    
    # 评论相关API
    path('comments/', views.CommentViewSet.as_view({'get': 'list', 'post': 'create'}), name='comment_list_create'),
    path('comments/<int:comment_id>/', views.CommentDeleteAPIView.as_view(), name='comment_delete'),
    
    # 保留原有的API
    path('posts/like/', views.like_post, name='like_post'),
    path('posts/star/', views.star_post, name='star_post'),
]

urlpatterns += router.urls